package com.niit.covid.topN;


import com.niit.covid.bean.CovidBean;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

/**
 * @author:Ys
 * @date: 2022年08月12日 17:37
 * @desc:
 */
public class CovidTopNReducer extends Reducer<CovidBean, LongWritable,CovidBean,LongWritable> {

    @Override
    protected void reduce(CovidBean key, Iterable<LongWritable> values, Context context) throws IOException, InterruptedException {

        //不遍历迭代器，此时的key就是分组中的第一个key就是州的确诊人数最多对应的数据
        context.write(key,values.iterator().next());
    }
}
